using UnityEngine;
using System.Collections;

public class ScoreKeeper : MonoBehaviour {
	
	
	public int score = 0;
	public string place = "";
	// Use this for initialization
	void Start () {
	
	
	
	}
	
	// Update is called once per frame
	void Update () {
	
			
	
	}
	
	public void addToScore(int sc)
	{
	score += sc;
	return;
	}
	
	public void addScore(string name, int scorer)
	{
	int newScore, oldScore;
	string newName, oldName;
		
	newName = name;
	newScore = scorer;
	
	for(int i = 0; i < 3; i++)
		{
			if(PlayerPrefs.HasKey(i+ "HScore")){
			if(PlayerPrefs.GetInt(i+"HScore")<newScore){
		oldScore = PlayerPrefs.GetInt(i+"HScore");
		oldName = PlayerPrefs.GetString(i+"HScoreName");
		PlayerPrefs.SetInt(i+"HScore", newScore);
		PlayerPrefs.SetString(i+"HscoreName", newName);
		newScore = oldScore;
		newName = oldName;
		
	}
		}
		else
		{
		      PlayerPrefs.SetInt(i+"HScore", newScore);
		      PlayerPrefs.SetString(i+"HScoreName", newName);
		      newScore = 0;
		      newName = "";
		      }
		      }
	}
	
	
	
	
}
